<?php
require_once ('../lib/config.php');
require_once ('../lib/facebook.php');
require_once ('../lib/friends.php');
require_once ('../lib/friend.php');
require_once ('../../simpletest/autorun.php');
require_once ('../lib/init.php');

class TestTemplate extends UnitTestCase {
    
    function setUp(){
        global $login_button;
        try{
            $me = getOneself();
        }catch(Exception $e){
            print($login_button);
            exit();
        }
    }
    
function array_icount_values($arr,$lower=true) { 
    $arr2=array(); 
    if(!is_array($arr['0'])){$arr=array($arr);} 
    foreach($arr as $k=> $v){ 
        foreach($v as $v2){ 
            if($lower==true) {$v2=strtolower($v2);} 
            if(!isset($arr2[$v2])){ 
                $arr2[$v2]=1; 
            }else{ 
                $arr2[$v2]++; 
            } 
        } 
    } 
    return $arr2; 
}
    

    //refer to http://www.simpletest.org/en/unit_test_documentation.html
    function testQuery(){ 
    
        $query = "SELECT uid1 FROM friend 
        			WHERE uid2 IN (
                    	SELECT uid1 FROM friend WHERE uid2 = me()
                	) AND uid1 IN (
                		SELECT uid1 FROM friend WHERE uid2 = me()
                	)";
            
        $response = callFQL($query);

        var_export($response);
        
        $arr = self::array_icount_values($response, false);   

        $this->assertNotNull($response);
        $this->assertTrue(is_array($response));
        
        
 
    }
    
    function testQuery2(){
        $data = array (
  572356495 => 15,
  1452136143 => 11,
  1676325929 => 13,
  '100000633970805' => 1,
  509836156 => 7,
  '100001041562777' => 2,
  509400009 => 2,
  550118413 => 4,
  555926326 => 4,
  612139051 => 7,
  711806955 => 7,
  1535926803 => 5,
  1559108118 => 4,
  '100001297801606' => 2,
  1281934594 => 2,
  1379851573 => 10,
  '100000526102422' => 14,
  '100001057185849' => 10,
  '100001437546761' => 16,
  720480184 => 4,
  15720738 => 3,
  534124579 => 7,
  542016885 => 1,
  732486215 => 10,
  1128757552 => 8,
  '100000243514929' => 2,
  '100000416787478' => 23,
  '100000525262538' => 18,
  '100000568852321' => 16,
  '100001442696712' => 1,
  1382591304 => 2,
  1436029649 => 1,
  1356805212 => 4,
  1637340897 => 2,
  1185268272 => 9,
  '100001474516590' => 14,
  '100000036440363' => 2,
  '100000545529457' => 2,
  1617980445 => 5,
  '100000571402532' => 8,
  612484233 => 2,
  765455726 => 2,
  '100000560912448' => 7,
  855739608 => 3,
  '100000767659366' => 8,
  '100000293254433' => 3,
  1535994324 => 3,
  1481610536 => 3,
  1468604886 => 2,
  645061280 => 1,
  '100001496104711' => 2,
  '100001573101794' => 1,
  '100001623437056' => 2,
  '100000591117659' => 2,
  '100001660120678' => 3,
  '100001794018281' => 2,
  '100000550522019' => 2,
  502925698 => 1,
  520468704 => 1,
  573168545 => 1,
  '100001875630715' => 1,
);

    }
}
?>
